Major Android Revamp [Wifi Only]#88
Major Android Revamp [Wifi Only]#88florian-guillemard merged 13 commits intoflutternetwork:masterfrom daadu:android-major-revamp
Conversation
…WithContext` and `initWithActivity` method; added `cleanup` method - [WifiIotPlugin] added `FlutterPlugin` and `ActivityAware` interfaces and override associated methods
- [example,android] upgraded `compileSDKVersion` to 29 and build tool to `4.1.0` and gradle to `6.5` - [example,android] migrated to androidx - [flutter] `pubspec.lock` upgraded
- [android] removed `WifiConfiguration` from import since deprecated, using full class name instead - [android] `loadWifiList`: only calling `WifiManager.startScan` for API < 28 - [readme] added warning (5) for "Enabling / Disabling WiFi module" for android platform
…ted`, implemented latest APIs for connecting - [readme] added warning for WEP deprecation for android platform
|
Great work @daadu! I tested your branch and it works fine, no errors or issues in the functions that we use: BTW there's a new official plugin that offers some "info" functions: https://github.com/flutter/plugins/tree/master/packages/wifi_info_flutter/wifi_info_flutter |
did you test with both sets: Android SDK >=29 and < 29; Android Embedding v1 and v2?
Will think of add this once the mammoth is dealt with! |
…xample app - [android] `isConnected`: moved old logic to `isConnectedDeprecated` and implemented with new APIs
|
@Alternadom |
…android.permission.ACCESS_FINE_LOCATION`
…ilable` - [android] `disconnect`: added new SDK implementations
…error for SDK >= 29 - [readme] added warning for Registering/Unregistering an Wifi Network - [readme] added warning for Connecting/Disconnecting on a network
|
Seems like Access Point methods are complicated using "mirrors" (hidden API) and there has been no issue raised for AP, hence this PR will not cover it. There for #83 is out of scope of this PR. |
|
@Niek @krishnaaro Please test and review this. |
|
unlinking #78 since AP is out of scope of this PR |
…cm.getActiveNetwork`, since it was returning network only when internet was present
|
@Alternadom This PR LGTM. Just to be safe can we release this as "alpa" on pub.dev, and then maybe after few weeks push to main version. I was thinking something like |
|
Although I found it later, this article/post is a good resource that explains and clarifies the new APIs. |
|
Thanks for the amazing work @daadu! Is this ready for merging yet? |
|
Great, I do see one exception when changing target SDK to 30, but not sure if it's coming from this plugin: W/ConnectionTracker(21779): Exception thrown while unbinding
W/ConnectionTracker(21779): java.lang.IllegalArgumentException: Service not registered: lp@3865763
W/ConnectionTracker(21779): at android.app.LoadedApk.forgetServiceDispatcher(Unknown Source:195)
W/ConnectionTracker(21779): at android.app.ContextImpl.unbindService(Unknown Source:11)
W/ConnectionTracker(21779): at android.content.ContextWrapper.unbindService(Unknown Source:2)
W/ConnectionTracker(21779): at ci.f(:com.google.android.gms.dynamite_measurementdynamite@204217081@20.42.17 (120400-0):1)
W/ConnectionTracker(21779): at ci.d(:com.google.android.gms.dynamite_measurementdynamite@204217081@20.42.17 (120400-0):2)
W/ConnectionTracker(21779): at lq.D(:com.google.android.gms.dynamite_measurementdynamite@204217081@20.42.17 (120400-0):10)
W/ConnectionTracker(21779): at lc.a(:com.google.android.gms.dynamite_measurementdynamite@204217081@20.42.17 (120400-0):2)
W/ConnectionTracker(21779): at ee.run(:com.google.android.gms.dynamite_measurementdynamite@204217081@20.42.17 (120400-0):3)
W/ConnectionTracker(21779): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
W/ConnectionTracker(21779): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/ConnectionTracker(21779): at ix.run(:com.google.android.gms.dynamite_measurementdynamite@204217081@20.42.17 (120400-0):6) |
|
@Niek Android SDK 30 (flutter/engine#20479) is not still supported by flutter engine in stable channel. Although it has been merged with master, so could be available Try with 29 and/or change the flutter channel and test with 30. |
|
@Niek Also did the functionality worked (disrespect of the logs)? |
|
@Niek Also the error looks like firebase plugin issue [ firebase/firebase-android-sdk#1662 ] |
|
@Niek Looks like firebase is not ready for v30!! |
|
#85 reported issue with internet connectivity after connecting to wifi. |
Major Android Revamp [Wifi Only]
Picking up with changes in Flutter (Android side) and Android SDK
TODO
androidxdependencies (example app) [docs]loadWifiList(poResult);WifiManager.startScan[deprecated in API 28] will not be supported in future, Lint is not giving warnings though.WifiManger.getScanResultsetEnabled(poCall, poResult);WifiManager.setWifiEnabled[deprecated in API 29] it will always failsconnect(poCall, poResult);connectTomethod called inconnectuses a lot of deprecated classes and methodsconnectTotoconnectToDeprecatedand add new implementation inconnectTofindAndConnect(poCall, poResult);connectisConnected(poResult);NetworkInfofrom importConnectionManager.getNetworkInfo[deprecated in API 23], Lint is not giving warnings though.isConnectedtoisConnectedDeprecatedand add new implementationdisconnect(poResult);WifiManger.disconnect[deprecated in API 29]ConnectivityManager.unregisterCallbackto disconnect for API >= 29removeWifiNetwork(poCall, poResult);WifiManager.getConfiguredNetworks[deprecated in API 29],WifiManager.removeNetwork[deprecated in API 29],WifiConfiguration[deprecated in API 29]isRegisteredWifiNetwork(poCall, poResult);WifiManager.getConfiguredNetworks[deprecated in API 29],WifiManager.removeNetwork[deprecated in API 29],WifiConfiguration[deprecated in API 29]Access Point methodsgetWiFiAPSSID(poResult);WifiConfiguration[deprecated in API 29]setWiFiAPSSID(poCall, poResult);WifiConfiguration[deprecated in API 29]isSSIDHidden(poResult);WifiConfiguration[deprecated in API 29]setSSIDHidden(poCall, poResult);WifiConfiguration[deprecated in API 29]getWiFiAPPreSharedKey(poResult);WifiConfiguration[deprecated in API 29]setWiFiAPPreSharedKey(poCall, poResult);WifiConfiguration[deprecated in API 29]sudoForResultand related methods.android.permission.ACCESS_COARSE_LOCATIONwithandroid.permission.ACCESS_FINE_LOCATION, since the documentation suggest it now.resolve deprecation warning whileflutter build apkNote for tester/reviewers
All the changes should be backward compatible, ie. should work with all flutter app as it is by just upgrading the package version. There for I encourage the reviewer to test both scenarios (>=29 and < 29; embedding v1 and v2).
To test this branch use the following in dependencies in puspec.yaml of your app:
This PR should potentially resolve following issues: